home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagd_f.zip / DIRS.SWG / 0042_Kill directories and files.pas < prev   
Pascal/Delphi Source File  |  1995-02-28  |  897b  |  45 lines

  1.  
  2. {$A+,B-,D-,E-,F-,G-,I-,L-,N-,O-,R-,S-,V-,X-}
  3. {$M 16384,0,655360}
  4.  
  5. uses dos;
  6.  
  7. procedure kill;
  8. var
  9.   sr  :  searchrec;
  10.   f   :  file;
  11. begin
  12.   findfirst('*.*',AnyFile xor VolumeId,sr);
  13.   repeat
  14.     if boolean(sr.Attr and Directory) and (sr.name[1]<>'.') then
  15.     begin
  16.       chdir(sr.name);
  17.       kill;
  18.       chdir('..');
  19.       rmdir(sr.name)
  20.     end
  21.     else if (sr.name[1]<>'.') then
  22.     begin
  23.       assign(f,sr.name);
  24.       setfattr(f,Archive);
  25.       erase(f)
  26.     end;
  27.     findnext(sr);
  28.   until DOSError<>0;
  29. end;
  30.  
  31. var
  32.   s : string;
  33.  
  34. begin
  35.   writeln('All files in directory and subdirectories will be deleted!');
  36.   write('Proceed? Y/N');
  37.   readln(s);
  38.   if upcase(s[1])<>'Y' then HALT;
  39.   kill
  40. end.
  41. -----
  42.  
  43. This one kills all files (in fact it'll sometimes depend on attributes) in
  44. directory and subdirectories. That's almost the same as making a tree...
  45.